from flask import Flask
from flask import session

app = Flask(__name__)
# 设置一个key
app.config["SECRET_KEY"] = "abcdhijkl123abcaaaqqq"

# 设置值
@app.route("/login")
def set_session():
    # 设置session值
    session["name"] = "Hylan"
    session["mobile"] = "10086"
    session["age"] = 25
    return "Session success."

# 获取值
@app.route("/index")
def index():
    # 获取值
    name = session.get("name")
    mobile = session.get("mobile")
    age = session.get("age")
    # 获取值
    content = "<p>姓名:%s</p><p>联系手机:%s</p><p>年龄:%s</p>"%(name,mobile,age)
    return content


if __name__ == '__main__':
    app.run()